package testing.src.akash.java.code;


public class GetPowerByDivideAndConquer {

    LargeMultiply largeMultiply = new LargeMultiply();
	
	public StringBuffer multiply(StringBuffer base , StringBuffer power){
		StringBuffer product = new StringBuffer();
		int exponent = Integer.parseInt(power.toString());
		if(exponent%2 == 1 && exponent >1){
			exponent = exponent/2 ;
			StringBuffer modifiedPower = new StringBuffer(Integer.toString(exponent));
			power = modifiedPower ;
			product = multiply(base, power);
			product = largeMultiply.multiply(product,product);
			product = largeMultiply.multiply(base, product);
		}else if(exponent%2 == 0 && exponent >1){
			exponent = exponent/2 ;
			StringBuffer modifiedPower = new StringBuffer(Integer.toString(exponent));
			power = modifiedPower ;
			product = multiply(base, power);
			product = largeMultiply.multiply(product,product);
		}else if(exponent == 1 ){
			product = base;
		}
		return product;
	}

}
